/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.ex;

import java.io.FileOutputStream;
import java.util.Random;

/**
 * <p>Project: javase2203 - Ex1
 * <p>Powered by webrx On 2022-08-15 08:59:28
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) {
        Random rand = new Random();
        StringBuilder sbu = new StringBuilder();
        for (int i = 0; i < 5000; i++) {
            sbu.append(getStr(rand.nextInt(3,5)));
        }
        try(var f = new FileOutputStream("user.txt")){
            f.write(sbu.toString().getBytes());
        }catch(Exception e){
            e.printStackTrace();
        }

    }

    public static String getStr() {
        StringBuilder sbu = new StringBuilder();
        Random rand = new Random();
        int len = rand.nextInt(3, 16);
        String letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for (int i = 0; i < len; i++) {
            sbu.append(letter.charAt(rand.nextInt(letter.length())));
        }
        return sbu.toString();
    }

    public static String getStr(int len) {
        StringBuilder sbu = new StringBuilder();
        Random rand = new Random();
        String t = getStr();
        t = t.substring(0,1).toUpperCase().concat(t.substring(1));
        sbu.append(t);
        for (int i = 1; i < len-1; i++) {
            sbu.append(" "+getStr());
        }
        sbu.append(" "+getStr()+".\r\n");
        return sbu.toString();
    }
}
